/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - geometry/containment
// Copyright( c) 2015.  All Rights Reserved
//
// File:		AEStaticMeshInstance.inl
// Author:		Gianluca Belardelli
// Date:		19/06/2015
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AESTATICMESHINSTANCE_INL_
#define _AESTATICMESHINSTANCE_INL_

AE_FORCEINLINE void AEStaticMeshInstance::SetBoundingBox( const AEBoundingBox &bbBox )
{
	m_bbBoundingBox = bbBox;
}

AE_FORCEINLINE const AEBoundingBox &AEStaticMeshInstance::GetBoundingBox( void ) const
{
	return m_bbBoundingBox;
}

AE_FORCEINLINE void AEStaticMeshInstance::SetTransform( const AEMatrix4f &matTransform ) 
{ 
	m_matTransformation = matTransform; 
	//m_bTransformIsIdentity = m_matTransformation.IsIdentity();
}

AE_FORCEINLINE const AEMatrix4f &AEStaticMeshInstance::GetTransform( void ) const
{
	return m_matTransformation;
}

AE_FORCEINLINE AEINT32 AEStaticMeshInstance::GetSubmeshInstanceCount( void ) const
{
	return m_nNumSubmeshInstances;
}

AE_FORCEINLINE AEStaticSubmeshInstance *AEStaticMeshInstance::GetSubmeshInstance( AEINT32 nInstanceIndex ) const
{
	AEASSERT( nInstanceIndex >= 0 && nInstanceIndex < m_nNumSubmeshInstances );
	return &( m_lpSubmeshInstances[nInstanceIndex] );
}

AE_FORCEINLINE void AEStaticMeshInstance::SetClipSettings( AEFLOAT32 fNear, AEFLOAT32 fFar, const AEVector4f *lpvcClipRefPosition )
{
	for( AEINT32 i=0; i < m_nNumSubmeshInstances; i++ )
		m_lpSubmeshInstances[i].SetClipSettings( fNear, fFar, lpvcClipRefPosition );
}

AE_FORCEINLINE void AEStaticMeshInstance::SetClipMode( AEINT32 nFlags )
{
	for( AEINT32 i=0; i < m_nNumSubmeshInstances; i++ )
		m_lpSubmeshInstances[i].SetClipMode( nFlags );
}

AE_FORCEINLINE void AEStaticMeshInstance::SetDefaultClipSettings( const AEVector4f *lpvcClipRefOffset )
{
/*
  for (AEINT32 i=0; i<m_nNumSubmeshInstances; i++)
  {
    VisStaticSubmesh_cl *pSM = m_lpSubmeshInstances[i].GetSubmesh();
    VBaseGeometryInfo &data = pSM->GetGeometryInfo();
    if (data.m_fFarClipDistance>0.f || data.m_fNearClipDistance>0.f)
    {
      AEVector3f vOfs = data.m_vClipReference;
      if (pClipRefOffset) 
        vOfs += (*pClipRefOffset);
      m_lpSubmeshInstances[i].SetClipSettings(data.m_fNearClipDistance,data.m_fFarClipDistance, &vOfs);
    } else
    {
      m_lpSubmeshInstances[i].SetClipSettings(data.m_fNearClipDistance,data.m_fFarClipDistance, AENULL);
    }
  }
*/
}

AE_FORCEINLINE void AEStaticMeshInstance::SetVisibleBitmask( AEUINT32 uiMask )
{
/*
  for (AEINT32 i=0; i<m_nNumSubmeshInstances; i++)
  {
    AEUINT32 iFinal = GetMesh()->GetSubmesh(i)->GetGeometryInfo().m_iVisibleMask & iMask; // additionally filter with the mask that is part of the resource. This is 0xffffffff by default
    m_lpSubmeshInstances[i].SetVisibleBitmask(iFinal);
  }
*/
}

AE_FORCEINLINE AEUINT32 AEStaticMeshInstance::GetCollisionBitmask( void ) const
{
	return m_uiCollisionMask;
}

AE_FORCEINLINE AEStaticMeshInstance::AECollisionBehavior AEStaticMeshInstance::GetCollisionBehavior( void ) const
{
	return m_eCollisionBehavior;
}

AE_FORCEINLINE AEBOOL32 AEStaticMeshInstance::GetCastStaticShadows( void ) const
{
	return m_bCastStaticShadows;
}

AE_FORCEINLINE void AEStaticMeshInstance::SetCastStaticShadows( AEBOOL32 bStatus )
{
	m_bCastStaticShadows=bStatus;
}

AE_FORCEINLINE AEStaticMesh *AEStaticMeshInstance::GetMesh( void ) const
{
	return m_spMesh;
}

#endif // _AESTATICMESHINSTANCE_INL_
